package com.itnetwork.Action;

import javax.annotation.Resource;

import org.apache.struts2.json.annotations.JSON;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.itnetwork.Entity.Admin;
import com.itnetwork.ServiceImp.AdminServiceImp;
import com.opensymphony.xwork2.ActionSupport;
@Component("Login")
@Scope("prototype")
public class LoginAction extends ActionSupport
{
	private Admin admin;
	private AdminServiceImp adminServiceImp;
	private boolean success=false;
	private String msg;

	public String execute(){
		if(adminServiceImp!=null){
			if(admin!=null){
				System.out.println("admin init true");
				System.out.println("admin.aId="+admin.getAname());			
				if(adminServiceImp.match(admin)){
					this.success=true;
				}else{
					this.success=true;
				};
			}else{
				System.out.println("admin init false");
			}
			}else{	
				System.out.println("adminServiceImp init false");
				}
		return this.SUCCESS;
	}
	public Admin getAdmin() {
		return admin;
	}
	@JSON(serialize = true)
	public String getMsg() {
		return msg;
	}
	@JSON(serialize = true)
	public boolean isSuccess() {
		return success;
	}
	public void setAdmin(Admin admin) {
		this.admin = admin;
	}
	@JSON(serialize=false)
	public AdminServiceImp getAdminServiceImp() {
		return adminServiceImp;
	}
	@Resource(name="adminServiceImp")
	public void setAdminServiceImp(AdminServiceImp adminServiceImp) {
		this.adminServiceImp = adminServiceImp;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}

}
